import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';

/// 包信息服务
class PackageInfoService extends GetxService {
  static PackageInfoService get to => Get.find();

  late PackageInfo _packageInfo;

  /// 初始化
  Future<PackageInfoService> init() async {
    _packageInfo = await PackageInfo.fromPlatform();
    return this;
  }

  /// 应用名称
  String get appName => _packageInfo.appName;

  /// 包名
  String get packageName => _packageInfo.packageName;

  /// 版本号
  String get version => _packageInfo.version;

  /// 构建号
  String get buildNumber => _packageInfo.buildNumber;
}
